package projectpackage;

import java.util.Vector;

public class ClientState{
	String chatWindow, onlineWindow;
	boolean isconnected;
	Vector<String> usersOnline;
	boolean onlychangingvector;
	
	public ClientState()
	{
		usersOnline = new Vector<String>();
	}
	
	public void setChatWindow(String str, boolean only)
	{
		this.onlychangingvector = only;
		this.chatWindow = str;
	}
	
	public void addToVector(String str, boolean only)
	{
		this.onlychangingvector = only;
		if(!usersOnline.contains(str))
		{	
			usersOnline.addElement(str);
		}
		setOnlineWindow();
	}
	public void removeFromVector(String str, boolean only)
	{
		this.onlychangingvector = only;
		usersOnline.remove(str);
		setOnlineWindow();
	}
	
	public void clearVector(boolean only)
	{
		this.onlychangingvector = only;
		usersOnline.clear();
		setOnlineWindow();
	}
	
	public void setOnlineWindow()
	{
		onlineWindow = "";
		for(int i = 0; i < usersOnline.size(); i++)
		{
			if(!usersOnline.elementAt(i).isEmpty())
				this.onlineWindow += usersOnline.elementAt(i) + "\n";
		}
	}
	
	public void setConnection(boolean connection, boolean only)
	{
		this.onlychangingvector = only;
		this.isconnected = connection;
	}
}